

package Object;

import java.awt.Graphics;
import java.awt.Image;
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;


public class Trung implements DoiTuong {
    private int x;
    private int y;
    private Image img;
    
    private void init() {
        Path p = Paths.get(Paths.get("").toAbsolutePath().toString());
        String pimg = p.toString() + "//src//Images/egg.png";

        File fimg = new File(pimg);
        try {
            img = ImageIO.read(fimg);
        } catch (IOException ex) {
            Logger.getLogger(GioTrung.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
    public Trung(int _x, int _y) {
        init();
        
        x = _x;
        y = _y;
    }
    
    @Override
    public void tick() {
        y = y + BienToanCuc.tocdovatroi;         
    }
    
    @Override
    public void render(Graphics g) {
        g.drawImage(img, x, y, null);
    }
    
    @Override
    public int getX() {
        return x;
    }
    
    @Override
    public int getY() {
        return y;
    }
    
    @Override
    public void setX(int _x) {
        x = _x;
    }
    
    @Override
    public void setY(int _y) {
        y = _y;
    }
}
